# app.py
from flask import Flask, request, jsonify
from flask_cors import CORS

app = Flask(__name__)
CORS(app)  # 允许跨域请求

@app.route('/api/data', methods=['POST'])
def get_data():
    data = request.json
    # 打印接收到的数据
    print("Received data:", data)
    # 处理前端发送的数据
    response_data = {
        'message': 'Data received',
        'received_data': data
    }
    # 打印响应数据
    print("Sending response:", response_data)
    return jsonify(response_data)

if __name__ == '__main__':
    app.run(debug=True)
